/* -----------------------------------------------------------------------
 * Demonstration of how to write unit tests for dominion-base
 * Include the following lines in your makefile:
 *
 * testUpdateCoins: testUpdateCoins.c dominion.o rngs.o
 *      gcc -o testUpdateCoins -g  testUpdateCoins.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {
	int i, j;
    int k[29] = {curse, estate, duchy, province, copper, silver, gold, adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall, minion, steward, tribute, ambassador, cutpurse, embargo, outpost, salvager, sea_hag, treasure_map, 93, -1};
    printf ("TESTING getCost():\n");
    
    //No gamestate needed for this. Simply iterate over all possible cards and ensure they return the proper values
    for (i=0; i<(sizeof(k) / sizeof(int)); i++)
    {
#if (NOISY_TEST == 1)
	printf("Test card %d.\n", k[i]);
#endif
    	
        //call getCost function & store return value        
        j=getCost(k[i]);

        //only values 0-26 are valid. getCost returns -1 for all other card values.
        if(k[i] < 0 || k[i]>26) assert(j == -1);

        else

    	switch( k[i] ) 
		{
			case curse:
				assert(j==0);
				break;
			case estate:
				assert(j==2);
				break;			
			case duchy:
				assert(j==5);
				break;
			case province:
				assert(j==8);
				break;
			case copper:
				assert(j==0);
				break;
			case silver:
				assert(j==3);
				break;
			case gold:
				assert(j==6);
				break;
			case adventurer:
				assert(j==6);
				break;
			case council_room:
				assert(j==5);
				break;
			case feast:
				assert(j==4);
				break;
			case gardens:
				assert(j==4);
				break;
			case mine:
				assert(j==5);
				break;
			case remodel:
				assert(j==4);
				break;
			case smithy:
				assert(j==4);
				break;
			case village:
				assert(j==3);
				break;
			case baron:
				assert(j==4);
				break;
			case great_hall:
				assert(j==3);
				break;
			case minion:
				assert(j==5);
				break;
			case steward:
				assert(j==3);
				break;
			case tribute:
				assert(j==5);
				break;
			case ambassador:
				assert(j==3);
				break;
			case cutpurse:
				assert(j==4);
				break;
			case embargo: 
				assert(j==2);
				break;
			case outpost:
				assert(j==5);
				break;
			case salvager:
				assert(j==4);
				break;
			case sea_hag:
				assert(j==4);
				break;
			case treasure_map:
				assert(j==4);
				break;
		}
    	
    	
    }

    printf("getCost(): All tests passed!\n");

    return 0;
}
